A Wavelet Derivative Spectrum Length Method of TFBG Sensor Demodulation

Fibre optic sensors using tilted fibre Bragg grating (TFBG) have high sensitivity for refractive index measurements. In order to achieve good metrological parameters of the measurement, an appropriate method of spectrum demodulation must be used. The method proposed in the article is an improvement of the spectral length algorithm. The spectral length parameter is treated as the sum of the derivative filter responses. In the original version, the first difference of spectrum elements was used, while this article proposes to use the wavelet transform to calculate the numerical derivative approximation. The advantage of this solution is an easy way to select the level of smoothing filtration by changing the scale parameter. The derivation is appropriate even for a relatively low signal-to-noise level. The approximation of the spectral length by the derivative calculated using the wavelet transform eliminates the high-frequency noise of the optical signal. The absolute value of determined spectral derivatives after significant smoothing can be used to estimate the wavelength of the decay of modes. After analyzing experimental data and performing calculations, it turns out that this is a linear method with better resolution than the contour length algorithm.


Introduction
Tilted fibre Bragg grating (TFBG) has an interesting transmission spectrum that is sensitive to changes in several physical quantities such as temperature [1], bending [2], strain [3], and polarisation state [4]. TFBG gratings can also be used to measure several parameters simultaneously [5][6][7][8]. As with any fibre optic sensor, the main advantage is the small size of the sensor. The most interesting sensing application of such periodic structures is the measurement of the refractive index. The change in the grating spectrum under the influence of the surrounding refractive index (SRI) is significant and thus enables high-resolution measurement. Calibration and subsequent determination of the SRI value based on the transmission spectrum is not a simple task. Intuitive spectrum demodulation methods, such as the most popular envelope method [9], do not use all points of the measured transmission spectrum. It is a large number of measured wavelengths, which is the main advantage of spectrum measurement. It makes it possible to reduce the influence of noise on the determined SRI value and to obtain the algorithmic selectivity of the measurement.
By carrying out a literature review of the TFBG spectrum demodulation methods, a certain systematization of the methods can be made. A single mode can be analyzed for a narrower range of SRI changes [10]. Changes in the entire spectrum can be useful for measuring a wide range of refractive indices [9,11]. Demodulation may consist of indirect determination of the single mode wavelength shift or the so-called cut-off wavelength for the entire spectrum [12]. The amplitude spectral parameters can be the peak amplitude of a single mode or parameters such as the area occupied by all cladding modes. Global amplitude methods also include those that use neural network methods [13].
The biggest problem in global methods for determining cut-off wavelength shifts is the difficulty in ensuring the continuity of this parameter with small changes in the SRI. This difficulty results from the shape of the spectrum consisting of several dozen modes. The basic core mode related to the Bragg wavelength in tilted gratings depends on the effective refractive index of the core n eff , grating period Λ, but also on the tilt angle θ [14]: (1) The wavelength of the cladding resonances can be calculated taking into account the effective refractive index of the core n eff,cor and the cladding n eff,cla for the wavelength of a given mode [14]: n i e f f ,cor + n i e f f ,cla ·Λ cosθ . ( It is difficult to correctly determine the cut-off wavelength changes from one mode to the next. Intermediate values can only be approximated. This corresponds to relatively large jumps in the calculated SRI value. The method to reduce such jumps may be the averaging of the cut-off wave calculated separately for the lower and upper envelopes of the modes [15]. Reducing the distance between individual modal resonances is possible with double and shifted mode comb grating [16,17]. Techniques used for Surface plasmon resonance (SPR) in TFBG complete the review of spectrum demodulation methods. Spectral shifts of the SPR effect gratings are different than those of the TFBGs themselves. SPR spectrum demodulation methods cannot be directly applied to TFBG spectrum demodulation. However, they can be an inspiration to create new algorithms tailored to a given sensor. Spectrum demodulation methods with the SPR effect, similar to grids without this effect, can be divided into those that use changes in the position of certain spectral features along the wavelength [18] and changes in the transmission amplitude level of the spectrum. A specific range of wavelengths or a single mode can be analyzed. The use of mode amplitude changes as an indicator of SRI can be preceded by an analysis of the sensitivity of a certain range of modes. Such a procedure indicates the most sensitive mode and improves the resolution of the method [19].
From the review of the literature on the demodulation of TFBG spectra, it appears that the quantitative analysis of data measured with optical fibre periodic structures is based on a variety of mathematical techniques. They are aimed at extracting relevant information and improving metrological parameters such as measurement resolution and selectivity. One of the tasks of the developed algorithms is to remove high-frequency noise. Individual methods are developed for a specific type of measurement data. Many of these methods are suitably modified methods known and used in the field of signal processing. The SRI value can be determined based on the frequency distribution shift in the Fourier domain [20]. The optical spectrum can also be modulated by a system with a cavity [21]. For such a system, in the Fourier frequency spectrum, as the SRI increases, the band related to the frequency of the cladding modes decreases and then disappears. The measured signal can be pre-processed using methods such as Fourier transform. In relation to it, the wavelet transform has the advantage of preserving information about the frequency content while simultaneously localizing it in time. In addition, the signal can be represented using different scales. The wavelet transform is used to process spectrophotometric spectra. With its help, the measured signal is decomposed into components of relatively simple shapes, which are subject to scaling and shifting. It appears especially when there is significant noise in the measured spectra [22][23][24]. Its main applications are to replace very popular derivative spectrophotometry methods [25,26].
Calculation of derivatives in the analysis of absorbance spectra is a popular technique for enhancing interesting features, such as the separation of individual peaks from different components [27]. At the same time, the baseline and its fluctuations are compensated. Unfortunately, the determination of the first and subsequent derivatives reduces the signal-to-noise ratio. Real spectra can contain a significant amount of noise. The solution to this drawback is simultaneous filtration along with the determination of derivatives. Unfortunately, it can cause a change in the shape of the spectra and, thus, the loss of information. Differentiating filters should be characterized by the best representation of the spectrum for a specific band in which its signal characteristics are contained. At the same time, above the cut-off frequency, the signal should be attenuated, which corresponds to the reduction in the noise content. With small SNR values, the continuous wavelet transform (CWT) [28] is suitable for determining derivatives. If the spectrum consists of spectral lines with shapes similar to Gaussian ones, then for individual peaks (maximums in the spectrum) for the first derivative, we obtain appropriate zero crossings. In the presence of noise, reducing its level is always associated with a simultaneous reduction in the high-frequency elements of the signal.
In this article, we propose to develop the spectral contour length method using the wavelet transform. We treat the length of the spectrum as a parameter on the basis of which we determine the SRI value [29]. However, for the basic version of this method, the length parameter is calculated as the sum of the elements of the differentiating filter (first difference). The development and improvement of this method consist of determining the derivative of the measured spectrum using the wavelet transform. This leads to noise filtration and improved measurement resolution. Then we use the shape of the spectral derivative to estimate the cut-off mode wavelength. This parameter moves linearly along the wavelength axis with increasing SRI.

Derivation of Derivatives Using the Wavelet Transform
Wavelet transform of a function f (t) at scale s (dilation parameter) and translation parameter b is expressed by the following integral: where ψ(t) is a finite energy continuous function called a mother wavelet. The above integral for a given scale s can be expressed using the convolution operation as [28]: Convolution is an operation that is performed during filtration. If we assume that the function ψ(t) is the impulse response of the filter, then the result of the transform is the response of such a filter to the input signal. Thus let us write Equation (4) as the filtering equation of the input signal x(b), transforming it into the output signal y(b): Equation (5) can be transformed on both sides using the Fourier transform. Taking into account the scaling of the mother wavelet, for a given scale s, we write [30]: Therefore, the spectrum of the mother function dilated through s will determine the type of filtering in the frequency domain. If the function ψ(t) was created using the smooth derivative of the function Θ(t): which has a fast decay property confirmed by the vanishing moment. As a result, the wavelet transform on a given scale can be written as [31]: So, we can write Equation (7) in the domain of the Fourier transform: At the same time, attention should be paid to the shape of the spectrum of the function θ(−s·ω). For an ideal derivative filter, the spectrum of this function should be a constant component. The condition for differentiation with the use of the wavelet transform is that the function θ(t) has the character of the impulse response of the low-pass filter. Differentiation will, therefore, only take place within a certain and limited frequency range. The wavelet transforms for a given scale is a low-pass differentiator filter. The dilation parameter changes the cut-off frequency of low-band filtration and, thus, the range of frequencies for which differentiation occurs. The properties of the derivative approximation using CWT depend mainly on the analysis wavelet used. The greater blurring of shapes occurs when the scale parameter is increased ( Figure 1).
Sensors 2023, 23, x FOR PEER REVIEW which has a fast decay property confirmed by the vanishing moment. As a res wavelet transform on a given scale can be written as [31]: So, we can write equation 7 in the domain of the Fourier transform: At the same time, attention should be paid to the shape of the spectrum of the f (− • ). For an ideal derivative filter, the spectrum of this function should be a c component. The condition for differentiation with the use of the wavelet transform the function ( ) has the character of the impulse response of the low-pass filter. entiation will, therefore, only take place within a certain and limited frequency ran wavelet transforms for a given scale is a low-pass differentiator filter. The dilation eter changes the cut-off frequency of low-band filtration and, thus, the range of fr cies for which differentiation occurs. The properties of the derivative approximatio CWT depend mainly on the analysis wavelet used. The greater blurring of shapes when the scale parameter is increased ( Figure 1). The improvement of the signal-to-noise ratio is obtained by increasing the sc rameter, which causes stronger low-band filtering. For a smaller scale parame wavelet transform has a better resolution in the fundamental domain (typically tim worse in the frequency domain. The scale-dependent expression (− • ) is quency response of the filter from equation 4. Increasing the scale means narrow frequency spectrum of the wavelet filter. This also corresponds to a reduction in th lution of the processed transmission spectra. The optimal selection of the dilation cient, therefore, depends on the shape of the signal and the signal-to-noise ratio. It based on an analysis of the shape of the obtained derivatives. Comparing the wav merical derivative with the derivative calculated analytically for test signals for scale factors, the resolution of the spectra (peak widths) is similar. An increase in lation scale results in greater smoothing and reduction in the processed peaks in th cal signal ( Figure 2). The improvement of the signal-to-noise ratio is obtained by increasing the scale parameter, which causes stronger low-band filtering. For a smaller scale parameter, the wavelet transform has a better resolution in the fundamental domain (typically time) and worse in the frequency domain. The scale-dependent expression ψ(−s·ω) is the frequency response of the filter from equation 4. Increasing the scale means narrowing the frequency spectrum of the wavelet filter. This also corresponds to a reduction in the resolution of the processed transmission spectra. The optimal selection of the dilation coefficient, therefore, depends on the shape of the signal and the signal-to-noise ratio. It is often based on an analysis of the shape of the obtained derivatives. Comparing the wavelet numerical derivative with the derivative calculated analytically for test signals for small-scale factors, the resolution of the spectra (peak widths) is similar. An increase in the dilation scale results in greater smoothing and reduction in the processed peaks in the optical signal ( Figure 2).

Derivatives and Contour Length for TFBG Spectra
The TFBG spectrum consists of dozens of cladding modes. This spectrum de on the tilt angle of the refractive index changes. Figure 3 shows an example of the ured spectrum of the TFBG grating with 6 degrees tilt. We carried out the measur without averaging (repeating) the spectra in the spectrum analyzer. As a result, the ured spectrum has a relatively high noise content. The basis of the demodulation rithm, referred to as the length of the spectrum contour or the length of the spectr the determination of the sum of the differences between successive values of the spe amplitudes. This corresponds to the sum of the first derivative of the function. Thi rithm was proposed for the analysis of spectra of FTIR spectrometers [32,33]. The ential equation of a suitable digital filter with a finite impulse response length can b ten as follows: where [ ] is the input signal of the filter, which in the considered aspect is the me transmission spectrum. The shape of the output signal [ ] of the filter for an ex spectrum is shown in Figure 3b. A characteristic feature of derivatives is the amplif of high-frequency noise. This phenomenon is very well visible in the spectrum in 3b. In the range of 1500-1505 nm, the noise is even more visible than the derivat individual transmission peaks. In the further part of the spectrum, the noise is against the background of the proper signal with larger amplitudes. The derivati also be computed using the wavelet transform. An example spectrum calculated continuous wavelet transform, Gauss wavelet, and scale 10 is shown in Figure 3c paring the spectra from Figure 3b,c, a significant reduction in noise for calculations using the wavelet transform is noticeable.

Derivatives and Contour Length for TFBG Spectra
The TFBG spectrum consists of dozens of cladding modes. This spectrum depends on the tilt angle of the refractive index changes. Figure 3 shows an example of the measured spectrum of the TFBG grating with 6 degrees tilt. We carried out the measurement without averaging (repeating) the spectra in the spectrum analyzer. As a result, the measured spectrum has a relatively high noise content. The basis of the demodulation algorithm, referred to as the length of the spectrum contour or the length of the spectrum, is the determination of the sum of the differences between successive values of the spectrum amplitudes. This corresponds to the sum of the first derivative of the function. This algorithm was proposed for the analysis of spectra of FTIR spectrometers [32,33]. The differential equation of a suitable digital filter with a finite impulse response length can be written as follows: where x[n] is the input signal of the filter, which in the considered aspect is the measured transmission spectrum. The shape of the output signal y[n] of the filter for an example spectrum is shown in Figure 3b. A characteristic feature of derivatives is the amplification of high-frequency noise. This phenomenon is very well visible in the spectrum in Figure 3b. In the range of 1500-1505 nm, the noise is even more visible than the derivatives of individual transmission peaks. In the further part of the spectrum, the noise is visible against the background of the proper signal with larger amplitudes. The derivative can also be computed using the wavelet transform. An example spectrum calculated using continuous wavelet transform, Gauss wavelet, and scale 10 is shown in Figure 3c. Comparing the spectra from Figure 3b,c, a significant reduction in noise for calculations made using the wavelet transform is noticeable. The length of the spectrum is a parameter indicating the changes in the spectrum associated with the leak of individual cladding modes. The decrease in the spectral length value is correlated with the increase in the SRI value. We calculate the length of the spectrum by summing up the absolute value of the derivative filter response: If the spectrum of the first derivative calculated using the wavelet transform (wavelet filter) is marked as y w [n] the length of the spectrum will then be: The length of the spectrum is a parameter indicating the changes in the spectrum associated with the leak of individual cladding modes. The decrease in the spectral length value is correlated with the increase in the SRI value. We calculate the length of the spectrum by summing up the absolute value of the derivative filter response: In the first experiment, 19 glucose concentrations with distilled water were measured. SRI values ranged from 1.333 to 1.3606. A 6 • tilt grating was fabricated by the phase mask method using an excimer laser (Coherent Inc., Santa Clara, CA, USA). Before the recording process, the single-mode optical fibre was placed in a hydrogen chamber in order to increase its sensitivity to laser radiation. During the refractive index measurements, a super-luminescent diode (SLED) S5FC1005S (Thorlabs Inc., Newton, NJ, USA) was used as the radiation source. The transmission spectrum of the gratings would be measured with an AQ6370D optical spectrum analyzer (Yokogawa, Tokyo, Japan) with a resolution of 0.004 nm. For each SRI value, 20 spectral measurements were made. Example spectra are shown in Figure 4.
If the spectrum of the first derivative calculated using the wavelet transform (wavelet filter) is marked as [ ] the length of the spectrum will then be: In the first experiment, 19 glucose concentrations with distilled water were measured. SRI values ranged from 1.333 to 1.3606. A 6° tilt grating was fabricated by the phase mask method using an excimer laser (Coherent Inc., Santa Clara, Califromia, USA). Before the recording process, the single-mode optical fibre was placed in a hydrogen chamber in order to increase its sensitivity to laser radiation. During the refractive index measurements, a super-luminescent diode (SLED) S5FC1005S (Thorlabs Inc., Newton, New Jersey, USA) was used as the radiation source. The transmission spectrum of the gratings would be measured with an AQ6370D optical spectrum analyzer (Yokogawa, Tokyo, Japan) with a resolution of 0.004 nm. For each SRI value, 20 spectral measurements were made. Example spectra are shown in Figure 4.  Figure 5 shows the characteristics of the dependence of the normalized contour length depending on the SRI. The range of the spectrum for which the contour length was calculated is shown in Figure 4. Increasing the scale of the wavelet filter causes it to become a derivative filter with an additional low-pass filtering effect. The differentiated spectrum becomes smoother and has smaller amplitudes. The length of the spectral contour for a larger scale will have smaller values. If we normalize this length to unity, then for the same range of wavelengths, its value for the maximum measured SRI will have a greater value than in the case of calculation using the first difference method ( Figure 5). In the course of the research, both continuous and discrete wavelet transforms were analyzed. Different types of wavelets were also tested [34]. The Gauss-type wavelet for the continuous wavelet derivative was used for the calculations. Calculations of the spectrum derivative were performed on a scale from 2 to 100. The best resolution was obtained on a scale of 40.   Figure 5 shows the characteristics of the dependence of the normalized contour length depending on the SRI. The range of the spectrum for which the contour length was calculated is shown in Figure 4. Increasing the scale of the wavelet filter causes it to become a derivative filter with an additional low-pass filtering effect. The differentiated spectrum becomes smoother and has smaller amplitudes. The length of the spectral contour for a larger scale will have smaller values. If we normalize this length to unity, then for the same range of wavelengths, its value for the maximum measured SRI will have a greater value than in the case of calculation using the first difference method ( Figure 5). In the course of the research, both continuous and discrete wavelet transforms were analyzed. Different types of wavelets were also tested [34]. The Gauss-type wavelet for the continuous wavelet derivative was used for the calculations. Calculations of the spectrum derivative were performed on a scale from 2 to 100. The best resolution was obtained on a scale of 40.

Comparison of First Difference and Wavelet Transform for Calculation of Derivative and Spectrum Length
The leak of the cladding modes and their envelope shifting towards longer wavelengths with the increase in the SRI value can be used as a method of spectrum demodulation. The shifting of the cut-off wavelength and the leak of successive modes is linear with increasing SRI. This property makes the methods of SRI determination that use an indirect calculation of the cut-off wavelength to be methods with good linearity. The simplest of these methods is to determine the maximum of the first derivative of the envelope of cladding modes. In the case of a spectral contour, the cumulative version can be used for this as a wavelength-dependent function. Another option is to calculate the derivative from the absolute value of the spectrum derivative shown in Figure 6. Since it is a quantity with slow changes with respect to the wavelength, the function of the contour absolute value should be strongly smoothed before determining the derivatives (Figure 7). For this purpose, a non-causal Gaussian moving average filter was used. A properly smoothed curve is obtained for the length of the impulse response of the filters above 1200. The derivative of the smooth curve in Figure 7 is shown in Figure 8. Figure 9 shows the dependence of the wavelength of the maximum derivative of the smoothed absolute value of the first difference of the TFBG spectrum on the SRI coefficient. Table 1 presents a comparison of the resolution for the four methods considered. In both types of methods, derivatives calculated using the wavelet transform give better results. The leak of the cladding modes and their envelope shifting towards longer wavelengths with the increase in the SRI value can be used as a method of spectrum demodulation. The shifting of the cut-off wavelength and the leak of successive modes is linear with increasing SRI. This property makes the methods of SRI determination that use an indirect calculation of the cut-off wavelength to be methods with good linearity. The simplest of these methods is to determine the maximum of the first derivative of the envelope of cladding modes. In the case of a spectral contour, the cumulative version can be used for this as a wavelength-dependent function. Another option is to calculate the derivative from the absolute value of the spectrum derivative shown in Figure 6. Since it is a quantity with slow changes with respect to the wavelength, the function of the contour absolute value should be strongly smoothed before determining the derivatives (Figure 7). For this purpose, a non-causal Gaussian moving average filter was used. A properly smoothed curve is obtained for the length of the impulse response of the filters above 1200. The derivative of the smooth curve in Figure 7 is shown in Figure 8.  The leak of the cladding modes and their envelope shifting towards longer wave lengths with the increase in the SRI value can be used as a method of spectrum demodu lation. The shifting of the cut-off wavelength and the leak of successive modes is linea with increasing SRI. This property makes the methods of SRI determination that use a indirect calculation of the cut-off wavelength to be methods with good linearity. The sim plest of these methods is to determine the maximum of the first derivative of the envelop of cladding modes. In the case of a spectral contour, the cumulative version can be use for this as a wavelength-dependent function. Another option is to calculate the derivativ from the absolute value of the spectrum derivative shown in Figure 6. Since it is a quantit with slow changes with respect to the wavelength, the function of the contour absolut value should be strongly smoothed before determining the derivatives (Figure 7). For th purpose, a non-causal Gaussian moving average filter was used. A properly smoothe curve is obtained for the length of the impulse response of the filters above 1200. The de rivative of the smooth curve in Figure 7 is shown in Figure 8.     Figure 9 shows the dependence of the wavelength of the maximum derivative of the smoothed absolute value of the first difference of the TFBG spectrum on the SRI coefficient. Table 1 presents a comparison of the resolution for the four methods considered. In both types of methods, derivatives calculated using the wavelet transform give better results.   Figure 9 shows the dependence of the wavelength of the maximum derivative of the smoothed absolute value of the first difference of the TFBG spectrum on the SRI coefficient. Table 1 presents a comparison of the resolution for the four methods considered. In both types of methods, derivatives calculated using the wavelet transform give better results.    The main disadvantage of the methods determining the wavelength of the mode leak shifting with the SRI is the presence of steps depending on this wavelength from the SRI.
Smoothing the spectrum derivative with the use of a long impulse response FIR filter seems to eliminate this effect. However, in order to verify this, glucose solutions with very small differences in SRI values were measured. In the second experiment, 21 glucose concentrations with distilled water were measured. SRI values ranged from 1.374 to 1.3433. The TFBG spectrum was measured for each single SRI value twenty times. Parts of example spectra in which the greatest changes occur under the influence of SRI in this range are shown in Figure 10. Since the resolution of the spectrometer was 0.004 nm, the number of data points between the spectral peaks is about 320. This value decreases with the wavelength. Similarly to the first set of experimental data, calculations were carried out fo four considered methods. The measurement characteristics of the determined cu wavelength as a function of SRI are shown in Figures 11 and 12. They show the chara istics for the maximum derivative value of the rectified and smoothed contour le spectrum in two cases. They differ in the length of the impulse response of the smoo filter. If the impulse response is too short, there are steps in the characteristic. This i to the jump of the maximum of the second derivative from the first to the next mode effect can be explained by analyzing Figure 13a. If we extend the length of the filte value of the first derivative of the spectrum becomes smooth without steps, as show Figure 13b. The impulse response length of the filter for Figure 13a was 500, whi Figure 13b, it was 1500.  Similarly to the first set of experimental data, calculations were carried out for the four considered methods. The measurement characteristics of the determined cut-off wavelength as a function of SRI are shown in Figures 11 and 12. They show the characteristics for the maximum derivative value of the rectified and smoothed contour length spectrum in two cases. They differ in the length of the impulse response of the smoothing filter. If the impulse response is too short, there are steps in the characteristic. This is due to the jump of the maximum of the second derivative from the first to the next mode. This effect can be explained by analyzing Figure 13a. If we extend the length of the filter, the value of the first derivative of the spectrum becomes smooth without steps, as shown in Figure 13b. The impulse response length of the filter for Figure 13a was 500, while for Figure 13b, it was 1500. spectrum in two cases. They differ in the length of the impulse response of the smoothing filter. If the impulse response is too short, there are steps in the characteristic. This is due to the jump of the maximum of the second derivative from the first to the next mode. This effect can be explained by analyzing Figure 13a. If we extend the length of the filter, the value of the first derivative of the spectrum becomes smooth without steps, as shown in Figure 13b. The impulse response length of the filter for Figure 13a was 500, while for Figure 13b, it was 1500. Figure 11. The wavelength of the maximum derivative value of the contour spectrum absolute value is calculated with the first difference method for two lengths of smoothing filters.  Figure 11. The wavelength of the maximum derivative value of the contour spectrum absolute value is calculated with the first difference method for two lengths of smoothing filters. Taking the derivative of a smooth function also yields a smooth function. The wavelength of the maximum of such a function moves linearly with increasing SRI. The stepped characteristics of Figures 11 and 12 would mean an SRI resolution of 0.002 (2 × 10 −3 ), while a sufficiently long filter allows a resolution of 10 −5 ( Table 2). Figure 13. The derivative of the smoothed absolute value of the first difference of the TFBG spectrum for two lengths of the smoothing filter.  Taking the derivative of a smooth function also yields a smooth function. The wavelength of the maximum of such a function moves linearly with increasing SRI. The stepped characteristics of Figures 11 and 12 would mean an SRI resolution of 0.002 (2 × 10 −3 ), while a sufficiently long filter allows a resolution of 10 −5 ( Table 2).   Taking the derivative of a smooth function also yields a smooth function. The wavelength of the maximum of such a function moves linearly with increasing SRI. The stepped characteristics of Figures 11 and 12 would mean an SRI resolution of 0.002 (2 × 10 −3 ), while a sufficiently long filter allows a resolution of 10 −5 (Table 2). Table 2. Comparison of the resolution for the contour length methods and the maximum derivative value of the contour in the case of the derivative calculated by the first difference method and the wavelet transform method.

Conclusions
The method of contour (spectra) length has been proposed to solve problems in the measurement of spectra with FTIR spectrometers. It also proved effective in demodulating the TFBG spectra. It has become a popular method in the scientific community dealing with TFBGs, as evidenced by the number of citations in the first article. In the basic version, this is the numerically simplest method because the sum of the absolute values of the first signal (spectrum) differences is calculated. The first difference is the approximation of the spectrum derivative. Hence, the contour length method can be extended to the calculation of the first derivative by other methods. This article proposes an algorithm for calculating the approximation of spectral derivatives using the wavelet transform. We have shown that this method works well in the case of noise in the measured spectra. By selecting the appropriate scale of the wavelet, the resolution of the algorithm was improved compared to the first difference method. In addition, it was shown that the method of the maximum derivative of the smoothed (filtered) absolute derivative of the transmission spectrum is characterized by good linearity. A noteworthy achievement during the work on this article is the demonstration of the linearity of the cut-off wavelength determination characteristics, even with very small changes in SRI. This property is ensured by a properly selected smoothing filter.
Author Contributions: S.C. and K.S. contributed to the idea of this work. S.C. and M.W. conceived and designed the experiments; M.W. and P.P. performed the experiments; S.C., K.S., M.W. and P.P. performed data analysis. S.C. developed demodulation algorithms. The content of the article was written mainly by S.C. All authors have read and agreed to the published version of the manuscript.